home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 612 < prev    next >
Internet Message Format  |  1996-08-06  |  3KB

  1. Path: sundog.tiac.net!stanr
  2. From: stanr@tiac.net (Stan Ryckman)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Prefixing functions with return type..
  5. Date: 20 Mar 1996 16:07:57 GMT
  6. Organization: Amber & Sneakers Fan Club
  7. Message-ID: <4ipagt$g53@sundog.tiac.net>
  8. References: <4hstf8$jf3@cybernews.cyberus.ca> <1996Mar14.080731.15076@Watt.COM> <1996Mar18.201616.6958@Watt.COM>
  9. NNTP-Posting-Host: sunspot.tiac.net
  10.  
  11. In article <1996Mar18.201616.6958@Watt.COM>,
  12. Adrian P Stephens  <aps@symbionics.co.uk> wrote:
  13. :[ posted for aps@symbionics.com by steve@Watt.COM ]
  14.  
  15. [hope I got the attributions right]
  16.  
  17. :Love them or loath them,  standards are important to any company.  Ours
  18.  
  19. Agreed, but they need to be sensibly chosen.
  20.  
  21. :has "C" coding standards which require this kind of thing.   Initially
  22. :I was against it,  because it makes things cluttered,   lengthens lines
  23. :of code and makes for more typing.
  24. :
  25. :Our standards also require explicit
  26. :identification of the size returned if it is an integer.   This is of 
  27. :benefit if you are doing emulation/debugging without a symbolic emulator/
  28. :debugger (and how many do that??),   but otherwise doesn't allow you to
  29.  
  30. I believe there are tools that can produce the type information you
  31. need separately.  Furthermore, if there are large numbers of names
  32. in scope at most points, a design problem probably exists.
  33.  
  34. Also, it's a distinct anti-benefit if you need to type a debugger
  35. command such as:
  36.     break at psTxManagementPktTXP_NewTxBeaconPkt
  37. to set a breakpoint, for example.
  38.  
  39. :pretend you've got "opaque types" in "C".   Also,  for some things where
  40. :the type is not selected until compile time (e.g. integer sizes and 
  41. :size_t particularly) you cannot select a name which is legal in the
  42. :sense of these standards.
  43.  
  44. [snip]
  45.  
  46. :Here's an example from a bit of code I'm working on now:
  47. :
  48. :extern TX_MANAGEMENT_PKT * psTxManagementPktTXP_NewTxBeaconPkt(void);
  49. :
  50. :Elements required in our standard:
  51. :
  52. :   TX_MANAGEMENT_PKT  - all upper case because it's a typedef/struct
  53. :   p                  - pointer to ...
  54. :   sTxManagementPkt   - a structure of this type (but case converted)
  55. :   TXP                - name of module containing global export
  56. :   "NewTxBeaconPkt"   - What I orginally called the routine before
  57. :                      - I read our coding standards.
  58.  
  59. Standards like these sacrifice portabiliy, with what seems like
  60. no benefit.  (External identifiers, to be portable, must be unique in
  61. the first six characters, independent of case.)  It would seem to
  62. me that if such names *must* be mandated (which I'm against), the
  63. type information should be on the end, such as
  64.     NewTxBeaconPkt_psTxManagementPktTXP
  65. (also probably more readable).
  66.  
  67. Also, do you need to rename everything if you change some typedef
  68. from int to long?  (or do the company standards forbid typedefs?)
  69.  
  70. Cheers,
  71. Stan.
  72. --
  73. Stan Ryckman  (stanr@tiac.net)
  74.   (Apologies for non-responses or late responses to some posts;
  75.   .newsrc was trashed and I'm trying to get it back to where it was.)
  76.